package com.kuaiditu.assistant.ui.balance;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kuaiditu.assistant.R;
import com.kuaiditu.assistant.entity.BalanceProcess;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by Eenie on 2017/9/4.
 * Email: eeniework@gmail.com
 * Des:
 */

public class BalanceAdapter extends BaseQuickAdapter<BalanceProcess,BaseViewHolder> {

    SimpleDateFormat mSimpleDateFormat;
    public BalanceAdapter( @Nullable List<BalanceProcess> data) {
        super(R.layout.item_balance_process, data);
        mSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    }

    @Override
    protected void convert(BaseViewHolder helper, BalanceProcess item) {

        helper.setText(R.id.tv_des, item.getCourierProcessinfo_processTypeName())
                .setText(R.id.tv_time, mSimpleDateFormat.format(item.getCourierProcessinfo_createTime()))


                .setText(R.id.tv_count,
                        (item.getCourierProcessinfo_courierProcessinfo_seqFlag().equals("0") ? "+" : "-") +
                                String.valueOf(item.getCourierProcessinfo_dealMoney()))

                .setTextColor(R.id.tv_count,(item.getCourierProcessinfo_courierProcessinfo_seqFlag().equals("0")? mContext.getResources().getColor(R.color.green):mContext.getResources().getColor(R.color.pink)))

                .setText(R.id.tv_balance, String.format("余额：%s", item.getCourierProcessinfo_balance()));
    }
}
